<template>
	<div>
		<el-form-item v-if="$check_register_field('add', 'user_name', '/ordinary_users/view')" label="用户姓名"
			prop="user_name">
			<el-input id="user_name" v-model="form['user_name']" placeholder="请输入用户姓名"></el-input>
		</el-form-item>
		<!-- 隐藏用户编号输入框 -->
		<!-- <el-form-item v-if="$check_register_field('add','user_number','/ordinary_users/view')" label="用户编号" prop="user_number">
			<el-input id="user_number" v-model="form['user_number']" placeholder="请输入用户编号"></el-input>
		</el-form-item> -->
		<el-form-item v-if="$check_register_field('add', 'user_gender', '/ordinary_users/view')" label="用户性别"
			prop="user_gender">
			<el-select id="user_gender" v-model="form['user_gender']">
				<el-option v-for="o in list_user_gender" :key="o" :label="o" :value="o">
				</el-option>
			</el-select>
		</el-form-item>
		<el-form-item v-if="$check_register_field('add', 'department', '/ordinary_users/view')" label="所属部门"
			prop="department">
			<!-- 替换为下拉框 -->
			<el-select id="department" v-model="form['department']" placeholder="请选择所属部门">
				<el-option v-for="item in universityOrganizerList" :key="item" :label="item" :value="item"></el-option>
			</el-select>
		</el-form-item>
	</div>
</template>

<script>
import mixin from "@/mixins/component.js";

export default {
	mixins: [mixin],
	props: {
		form: {
			type: Object,
			default: function () {
				return {
					"user_name": '',
					"user_number": '',
					"user_gender": '',
					"department": '',
				}
			}
		},
	},
	data() {
		return {
			field: "ordinary_users_id",
			url_add: "~/api/ordinary_users/add?",
			url_set: "~/api/ordinary_users/set?",
			url_upload: "~/api/ordinary_users/upload?",
			list_user_gender: ['男', '女'],
			// 添加 universityOrganizerList 数据
			universityOrganizerList: [
				// 学校行政部门
				"学校教务处",
				"学校学生处",
				"学校团委",
				"学校体育部",
				"学校科研处",
				"学校国际交流处",
				"学校工会",

				// 学院层面
				"计算机学院",
				"机械工程学院",
				"电子信息学院",
				"经济管理学院",
				"外国语学院",
				"艺术设计学院",
				"生命科学学院",

				// 学生社团组织
				"篮球社团",
				"足球社团",
				"羽毛球社团",
				"乒乓球社团",
				"游泳协会",
				"武术协会",
				"健身俱乐部",
				"棋类社团",

				// 学术组织
				"数学建模协会",
				"科技创新协会",
				"哲学思辨社",
				"历史文化研究社",

				// 特殊机构
				"校学生会",
				"研究生会",
				"校友总会",
				"校图书馆",
				"校博物馆"
			],
			rules: {
				"user_name": [],
				// 移除用户编号必填规则
				"user_number": [],
				"user_gender": [],
				"department": [],
			}
		}
	},
	methods: {
		// 定义生成用户编号的方法
		generateUserNumber() {
			// 这里简单示例生成时间戳作为用户编号，你可以根据需求修改
			return Date.now().toString();
		}
	},
	created() {
		// 组件创建时生成用户编号
		this.form.user_number = this.generateUserNumber();
	}
}
</script>